package com.xiaoger.aop.aop.controller;

import com.xiaoger.aop.aop.aspect.AutoLog;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * aop测试接口
 *
 * @author xjx
 * @date 2022/5/6 16:24
 */
@Slf4j
@RestController
public class AopController {


    @GetMapping("/first")
    public String first() {
        return "执行了第一个方法不带参数";
    }

    @GetMapping("/second")
    public String second(@RequestParam(name = "second", required = false) String second) {
        log.info("获取参数为：{}", second);
        return "执行了第二个方法带参数";
    }

    /**
     * 模拟当前方法异常
     */
    @GetMapping("/third")
    public Object third() {
        return 1 / 0;
    }


    @AutoLog(value = "用来测试注解的使用", operateType = 1)
    @GetMapping("/four")
    public Object four() {
        return "执行了有注解的方法";
    }
}
